"""create a list of both the source IP and destination IP, and 
identify the firewall logs as well as identify the month, day,
time, scrIP and port, destIP and port"""
import re
inpfile = open('/home/rafael/project/example/samplelog', 'r')
x = 0
dstIP=[0]*256
srcIP=[0]*256
for line in inpfile:
    if re.search(".*F800",line):
        m = re.search("^(\w{3})\s{1,2}(\d{1,2})\s{1,2}(\d{1,2}\:\d{2}\:\d{2}).*?(\d{1,3}\.\d{1,3}\.\d{1,3})\.(\d{1,3})(:\d{1,5}).*?(\d{1,3}\.\d{1,3}\.\d{1,3})\.(\d{1,3})(:\d{1,5})",line)
        if m == None:
            #print line
            continue
            """detremin the traffic of the computers from 
            the local network"""
    #print line,
        #x= x+1
        #print m.group(1), m.group(2), m.group(3), m.group(4), m.group(5), m.group(6), m.group(7), m.group(8), m.group(9)
        #print m.group(6), m.group(7)
        if m.group(7) == "192.52.61":
            dstIP[int(m.group(8))]+=1
        if m.group(4) == "192.52.61":
            srcIP[int(m.group(5))]+=1
"""print the amount of traffic each dstIP of the 
network recives"""
outfile = open('/home/rafael/project/outfile/outfile', 'rw')
#outfileSrc = open('/home/rafael/project/outfile/outfileSrc', 'rw')
#d1= open('/home/rafael/project/gnuplot/d1.dat', 'w')
#for i in dstIP:
for i in range (len(dstIP)):
    print>>outfile, i, dstIP[i]
#for q in range (len(srcIP)):
    #print>>outfileSrc, q, srcIP[q]
#  print outfile>>d1
#"plot '%s' with boxes;" % (outfile)/
"""Import both gnuplot and eog, and run the dstIP data from 
outfile"""
from os import system, remove
system('gnuplot -persist /home/rafael/project/gnuplot/testplotDst')
system('eog d1_plot.png')


#system('gnuplot -persist /home/rafael/project/gnuplot/testplotSrc')
#system('eog d2_plot.png')
#remove('/home/rafael/project/gnuplot/testplot')
#from os import system, remove
#system('gimp /home/rafael/project/gnuplot/d1_plot.png')
#remove('d1_plot.png')                   
#print dstIP[0:255] 
#print srcIP[1:255]  
#print "The number of lines are", x
#        
#                    

